
def load_DIMACS(path):
    """
    Load a sentence from an open file
    The format is automatically detected.
    """
    sentences = []
    clause_number = 0
    body_flag = False
    with open(path,'r') as fp:
        for line in fp:
            if line.startswith('c'):
                continue
            if line.startswith('p '):
                body_flag = True
                problem = line.split()
                clause_number = problem[2]
                continue
            if line.startswith('%'):
                return body_flag,sentences, clause_number
            """要识别的主体部分"""
            if body_flag == True:
                clause = line.split()
                sentence = []
                for item in clause:
                    #sentence.append(int(item))
                    sentence.append(item)
                sentences.append(sentence[:-1])



if __name__ == "__main__":
    path = "input/uf20-91/uf20-01.cnf"
    print(load_DIMACS(path))
